package com.cloud.server.system.controller;

import cn.hutool.core.lang.Console;
import com.cloud.common.core.base.ApiResponse;
import com.cloud.common.core.base.ApiResponseEnum;
import com.cloud.server.system.feign.TestFeignService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.time.LocalDateTime;

/**
 * @Description:
 * @Auther: zhangxun
 * @Date: 2020/8/6 14:18
 */
@RestController()
@RequiredArgsConstructor
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Autowired
    private TestFeignService testFeignService;

    @GetMapping("/info")
    public ApiResponse test(){
        return ApiResponse.respond(ApiResponseEnum.SUCCESS,"febs-server-system");
    }

    @GetMapping("/user")
    public ApiResponse<Principal> currentUser(Principal principal) {
        return ApiResponse.respond(principal);
    }
    @GetMapping("/{name}")
    private ApiResponse findUser(@PathVariable(value = "name",required = false) String name){
        Console.log("获取用户信息成功，获取时间：{}", LocalDateTime.now());
        return ApiResponse.respond();
    }

    @GetMapping("/hello")
    public ApiResponse<String> hello(String name){
        log.info("Feign调用cloud-server-test的/hello服务");
        return this.testFeignService.hello(name);
    }
}